空间复杂度:衡量算法在运行过程中所需额外内存空间随输入规模增长而变化的程度,通常用 Big-O(O(·)) 表示(例如 O(1)、O(n)、O(n²))。常见语境下主要指额外空间(auxiliary space),不一定包含输入本身占用的存储。
The space complexity of this algorithm is O(n).
这个算法的空间复杂度是 O(n)。
Although the time complexity is acceptable, the space complexity becomes a bottleneck when the input size grows, especially due to recursion and auxiliary arrays.
尽管时间复杂度可以接受,但当输入规模增大时,空间复杂度会成为瓶颈,尤其是由于递归调用和辅助数组的使用。
/speɪs kəmˈplɛksɪti/
space 源自拉丁语 spatium(“空间、距离”),经由古法语进入英语;complexity 来自拉丁语 complexus(“交织在一起的”),引申为“复杂程度”。组合成 space complexity 后,在计算机科学中用于描述“内存占用随规模增长的复杂程度”。